/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jp.selfportrait.twonkyscrobbler4j;

import java.io.IOException;
import java.util.TimerTask;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;

/**
 *
 * @author kazuho
 */
public class Scrobbler extends TimerTask {

    public void run() {
        try {
            XMLReader reader;
            reader = XMLReaderFactory.createXMLReader();
            SAXContentsHandler handler = new SAXContentsHandler();
            reader.setContentHandler(handler);
            reader.parse(TwonkyScrobbler4J.urlString);
        } catch (IOException ex) {
            System.out.println("IO error: Check your network and URL to feed.");
            this.cancel();
        } catch (SAXException ex) {
            System.out.println("SAX error: Feed XML is invalid.  " +
                    "Restart TwonkyMedia Server.");
            this.cancel();
        }
    }
}
